package com.bluesky.lock;

import java.util.function.Consumer;
import java.util.function.Function;

public interface DistributeLock {

    /**
     * 上锁执行业务操作，上锁失败返回false
     * @param lockKey
     * @param consumer
     * @return
     */
    boolean accept(String lockKey, Consumer<String> consumer);


    /**
     * 上锁执行业务操作
     * @param lockKey
     * @param consumer
     * @param lockFailException  上锁失败将抛出异常
     */
    void accept(String lockKey, Consumer<String> consumer, Function<String,? extends RuntimeException> lockFailException);
}
